<html>
<head><meta charset="utf-8"><title>implicit token at startup · t-compiler/wg-parallel-rustc · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/index.html">t-compiler/wg-parallel-rustc</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/implicit.20token.20at.20startup.html">implicit token at startup</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="183713047"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/implicit%20token%20at%20startup/near/183713047" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Zoxc <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/implicit.20token.20at.20startup.html#183713047">(Dec 18 2019 at 02:19)</a>:</h4>
<p>We can avoid giving up the implicit token when creating the Rayon thread pool by changing the semantics of <code>build_scoped</code> so that it inherits the token from the caller and gives it to the first Rayon thread and also let the first Rayon thread execute the passed closure.</p>



<a name="183716428"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/implicit%20token%20at%20startup/near/183716428" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Zoxc <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/implicit.20token.20at.20startup.html#183716428">(Dec 18 2019 at 03:23)</a>:</h4>
<p><span class="user-mention" data-user-id="116122">@simulacrum</span>  Are you planning to fix this by not letting rustc return all tokens to cargo when you have a channel to each rustc process?</p>



<a name="183716654"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/implicit%20token%20at%20startup/near/183716654" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/implicit.20token.20at.20startup.html#183716654">(Dec 18 2019 at 03:26)</a>:</h4>
<p>It was our impression that a fix inside rayon is possibly non trivial or might point at deeper questions.</p>
<p>Current plan I believe is to keep track of the token count and just not release/acquire the first token, which should be relatively easy to implement hopefully.</p>



<a name="183716724"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/implicit%20token%20at%20startup/near/183716724" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/implicit.20token.20at.20startup.html#183716724">(Dec 18 2019 at 03:27)</a>:</h4>
<p>In particular I think <span class="user-mention" data-user-id="116009">@nikomatsakis</span> was not sure about whether this is pointing at some underlying problem with rayon or if it's something we should try to patch over ourselves.</p>



<a name="183716947"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/implicit%20token%20at%20startup/near/183716947" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/implicit.20token.20at.20startup.html#183716947">(Dec 18 2019 at 03:31)</a>:</h4>
<p>What you're proposing loosely sounds like a more invasive but maybe also more principled change.</p>



<a name="183717009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/implicit%20token%20at%20startup/near/183717009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/implicit.20token.20at.20startup.html#183717009">(Dec 18 2019 at 03:32)</a>:</h4>
<p>Though we do have the query latch which I think has the same problem as rayon</p>



<a name="183717030"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/implicit%20token%20at%20startup/near/183717030" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/implicit.20token.20at.20startup.html#183717030">(Dec 18 2019 at 03:33)</a>:</h4>
<p>(but not exactly sure there, since it is semi-plausible that we can't run into trouble there as we don't have a situation where all threads latch, but I'm not confident)</p>



<a name="183717443"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/implicit%20token%20at%20startup/near/183717443" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Zoxc <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/implicit.20token.20at.20startup.html#183717443">(Dec 18 2019 at 03:42)</a>:</h4>
<p>It's not that principled. It only fixes one case where it could happen. It can also happen when the main thread is waiting on some other thread.</p>



<a name="183745480"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/implicit%20token%20at%20startup/near/183745480" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/implicit.20token.20at.20startup.html#183745480">(Dec 18 2019 at 12:29)</a>:</h4>
<p>well, it's fine if the main thread releases its token</p>



<a name="183745491"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187679-t-compiler/wg-parallel-rustc/topic/implicit%20token%20at%20startup/near/183745491" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187679-t-compiler/wg-parallel-rustc/topic/implicit.20token.20at.20startup.html#183745491">(Dec 18 2019 at 12:29)</a>:</h4>
<p>we just can't have a rustc without tokens</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>